{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1, 'cuda',  3, print]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "hello\n"
    }
   ],
   "source": [
    "a[3]('hello')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "['1', '2', '', '3', '4', '5']"
     },
     "metadata": {},
     "execution_count": 19
    }
   ],
   "source": [
    "'1 2  3 4 5'.split(' ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "'12345'"
     },
     "metadata": {},
     "execution_count": 22
    }
   ],
   "source": [
    "''.join(['1', '', '2', '3', '4', '5'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "Help on built-in function join:\n\njoin(iterable, /) method of builtins.str instance\n    Concatenate any number of strings.\n    \n    The string whose method is called is inserted in between each given string.\n    The result is returned as a new string.\n    \n    Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'\n\n"
    }
   ],
   "source": [
    "help(''.join)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[1]"
     },
     "metadata": {},
     "execution_count": 24
    }
   ],
   "source": [
    "a = []\n",
    "a.append(1)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "Wall time: 0 ns\n"
    },
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[2, 3, 4]"
     },
     "metadata": {},
     "execution_count": 27
    }
   ],
   "source": [
    "%time\n",
    "a = [1, 2, 3]\n",
    "[e + 1 for e in a]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "Help on class map in module builtins:\n\nclass map(object)\n |  map(func, *iterables) --> map object\n |  \n |  Make an iterator that computes the function using arguments from\n |  each of the iterables.  Stops when the shortest iterable is exhausted.\n |  \n |  Methods defined here:\n |  \n |  __getattribute__(self, name, /)\n |      Return getattr(self, name).\n |  \n |  __iter__(self, /)\n |      Implement iter(self).\n |  \n |  __next__(self, /)\n |      Implement next(self).\n |  \n |  __reduce__(...)\n |      Return state information for pickling.\n |  \n |  ----------------------------------------------------------------------\n |  Static methods defined here:\n |  \n |  __new__(*args, **kwargs) from builtins.type\n |      Create and return a new object.  See help(type) for accurate signature.\n\n"
    }
   ],
   "source": [
    "help(map)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "9"
     },
     "metadata": {},
     "execution_count": 29
    }
   ],
   "source": [
    "def f(n):\n",
    "     return n**2\n",
    "\n",
    "f(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[1, 4, 9]"
     },
     "metadata": {},
     "execution_count": 30
    }
   ],
   "source": [
    "list(map(f, [1, 2, 3]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[1, 4, 9]"
     },
     "metadata": {},
     "execution_count": 31
    }
   ],
   "source": [
    "list(map(lambda n: n**2, [1, 2, 3]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [[1, 'a'], [2, 'c'], [5, 'b']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "Help on built-in function sort:\n\nsort(*, key=None, reverse=False) method of builtins.list instance\n    Stable sort *IN PLACE*.\n\n"
    }
   ],
   "source": [
    "help(a.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[[1, 'a'], [2, 'c'], [5, 'b']]"
     },
     "metadata": {},
     "execution_count": 45
    }
   ],
   "source": [
    "a.sort()\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[[1, 'a'], [5, 'b'], [2, 'c']]"
     },
     "metadata": {},
     "execution_count": 46
    }
   ],
   "source": [
    "a.sort(key=lambda x: x[1])\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[[2, 'c'], [5, 'b'], [1, 'a']]"
     },
     "metadata": {},
     "execution_count": 47
    }
   ],
   "source": [
    "a.sort(reverse=True,key=lambda x: x[1])\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "[[1, 'a'], [2, 'c'], [5, 'b']]"
     },
     "metadata": {},
     "execution_count": 50
    }
   ],
   "source": [
    "a = sorted(a)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "Help on built-in function sorted in module builtins:\n\nsorted(iterable, /, *, key=None, reverse=False)\n    Return a new list containing all items from the iterable in ascending order.\n    \n    A custom key function can be supplied to customize the sort order, and the\n    reverse flag can be set to request the result in descending order.\n\n"
    }
   ],
   "source": [
    "help(sorted)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "L = [print]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "a\nNone\n"
    }
   ],
   "source": [
    "print(L[0]('a'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "'1|2|3'"
     },
     "metadata": {},
     "execution_count": 57
    }
   ],
   "source": [
    "'|'.join('1 2 3'.split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "3.14\n"
    }
   ],
   "source": [
    "print(\"%.2f\" % 3.1415926)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "3.14\n"
    }
   ],
   "source": [
    "print(\"{:.2f}\".format(3.14159))"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}